
Zepto(function ($) {
	var startY = 0; 
	var nav_top = -50;//目标的高度负值
	var $floating;  //目标
	var $body;      //触控屏幕的相应位置
	var startOffsetTop;  //点击屏幕时目标相对父元素的Y位置 
	var startScrollY;   //点击屏幕时scroll的位置，用于Andriod的touchMove bug
	var startTime;
	var bIsAndr = isAnDriod();
	$floating = $(".floating-top");
	$body = $("body");
	
	//touchstart
	$body.on("touchstart", function (e) {
		var oTouch = e.touches[0];
		startY = oTouch.screenY;
		startOffsetTop = $floating.offset().top;
		//for Andriod兼容,假如不除这个bug，当先下滚不松手再上滚时，导航条不显示
		//可用不直接置顶nav的方法，上滚时才添加fixed样式执行动画，(添加动画结束等待?),下滚时判断是否有fixed的样式，有则去除
		//if (false && bIsAndr) {
		//    e.preventDefault();
		//    startScrollY = window.scrollY;
		//    //用于touchend后的继续滚动计算
		//    //var startTime = new Date().getTime();
		//}
			
	});

	//touchmove
	$body.on("touchmove", function (e) {
		var oTouch = e.touches[0];
		var nowY = oTouch.screenY;
		var dist = nowY - startY;
		fAminTheNav(startOffsetTop, nav_top, dist);
		//for Andriod兼容
		//if (false && bIsAndr) {
		//    fScrolling(startScrollY, dist);
		//}
		
	});
	//滚动屏幕
	function fScrolling(startScrollY, dist) {
		window.scroll(0, startScrollY - dist);
	}
	//显示或隐藏目标
	function fAminTheNav(startOffsetTop, nav_top, dist) {
		var actValue;
		if ((dist >= 0) || ((startOffsetTop < -nav_top) && dist > nav_top)) {
			actValue = 'translate3d(0,' + 0 + 'px,0)';
		} else {
			actValue = 'translate3d(0,' + nav_top + 'px,0)';
		}
		//$("#log").html(nowY);
		$floating.css({
			'-webkit-transform': actValue,
			'-moz-transform': actValue
		});
	}
	//是否andriod
	function isAnDriod() {
		if (navigator.userAgent.match(/Android/i)) {
			return true;
		} else {
			return false;
		}
	}
});
Zepto(function ($) {
	$(document).on("click", ".check-box", function () {
		$(this).toggleClass("checked");
	})
})


